package comviva_2014.SmartMapper;


import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
//import java.util.LinkedHashMap;
import java.util.List;
//import java.util.Map;
import java.util.NoSuchElementException;

public class Main_12_9 {

	public static void main(String[] args2) throws IOException {

		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] line = reader.readLine().split(" ");
		String fileName = line[0];
		if (line.length == 1) {
			System.out.println("READY");
			return;
		}

		// System.out.println("File Name: " + fileName);

		File f = new File(fileName);

		if (f.exists() == false) {

			System.out.println("FAILURE");
			return;
		}

		PrimitiveIntHashMap txn_ids = getTxnIds(line[1].split("=")[1]);
		PrimitiveIntHashMap ref_ids = getRefIds(line[2].split("=")[1]);

		if (txn_ids.size() == 0 && ref_ids.size() == 0) {
			System.out.println("FAILURE");
			return;
		}

		solve(fileName, txn_ids, ref_ids);

	}

	private static PrimitiveIntHashMap getTxnIds(String txn_ids_csv) {
		PrimitiveIntHashMap txn_ids_map = new PrimitiveIntHashMap(
				32);

		String[] arr = txn_ids_csv.split(",");

		for (String a : arr) {
			txn_ids_map.put(Arrays.hashCode(a.getBytes()), null);
		}

		return txn_ids_map;

	}

	private static PrimitiveIntHashMap getRefIds(String ref_ids_csv) {
		PrimitiveIntHashMap ref_ids_map = new PrimitiveIntHashMap(
				32);

		String[] arr = ref_ids_csv.split(",");

		for (String a : arr) {
			ref_ids_map.put(Arrays.hashCode(a.getBytes()), null);
		}

		return ref_ids_map;

	}

	private static void solve(String fileName, PrimitiveIntHashMap txn_ids,
			PrimitiveIntHashMap ref_ids) throws IOException {

		RandomAccessFile aFile = new RandomAccessFile(fileName, "r");
		FileChannel inChannel = aFile.getChannel();

		ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 1024 * 100);

		int txn_hash = -1;
		int ref_hash = -1;
		byte[] txn_bb = new byte[32];
		byte[] ref_bb = new byte[32];
		byte[] token = new byte[32];
		int token_hash = 1;
		int token_p = 0;
		byte b = (byte) 0;
		while (inChannel.read(buffer) > 0) {
			buffer.flip();
			

			while (buffer.hasRemaining()) {
				 b = buffer.get();
				// System.out.println((char)b);
				if (b == ',') {
					// txn_hash = Arrays.hashCode(token);
					txn_hash = token_hash;
					
					txn_bb = token;

					token_p = 0;
					token = new byte[32];
					token_hash = 1;
				} else if (b == '\r' || b == '\f' || b == '\n') {
					if (token_p == 0)
						continue;
					// ref_hash = Arrays.hashCode(token);
					ref_hash = token_hash;
					ref_bb = token;
					token_p = 0;
					token = new byte[32];
					token_hash = 1;

					if (txn_ids.containsKey(txn_hash)) {
						txn_ids.put(txn_hash, new String(ref_bb));
					}
					if (ref_ids.containsKey(ref_hash)) {
						ref_ids.put(ref_hash, new String(txn_bb));
					}
				} else {
					token[token_p++] = b;
					// token_hash = ((token_hash << 5) + token_hash) + b;
					token_hash = 31 * token_hash + b;

				}
			}

			buffer.clear();
		}

		List<String> resList = new ArrayList<String>();
		
//		System.out.println(txn_ids.size());
	//	System.out.println(ref_ids.size());
		
		for (PrimitiveIntHashMap.Entry e : txn_ids.entrySet()) {
			resList.add(e.getValue());
		}
		for (PrimitiveIntHashMap.Entry e : ref_ids.entrySet()) {
			resList.add(e.getValue());
		}

		StringBuilder res = new StringBuilder();
		for (int i = 0; i < resList.size(); i++) {
			if (resList.get(i) == null) {
				res.append("FAILURE");
			} else {
				res.append(resList.get(i));
			}
			if (i < resList.size() - 1)
				res.append(",");

		}
		System.out.print(res);

		inChannel.close();
		aFile.close();

	}

	static long djb_hash(byte[] buff, int start, int end) {
		long hash = 5381;

		for (int i = start; i <= end; i++) {
			hash = ((hash << 5) + hash) + buff[i];
		}

		return hash;
	}
	static class PrimitiveIntHashMap {
		static final int DEFAULT_INITIAL_CAPACITY = 16;
		static final int MAXIMUM_CAPACITY = 1 << 30;
		static final float DEFAULT_LOAD_FACTOR = 0.75f;
		Entry[] table;
		LinkedEntry header;

		int size;
		int threshold;
		final float loadFactor;

		public PrimitiveIntHashMap(int initialCapacity) {
			this.loadFactor = 0.75f;
			threshold = (int) (initialCapacity * loadFactor);
			table = new Entry[initialCapacity];

			// init
			header = new LinkedEntry(-1, -1, null, null);
			header.before = header.after = header;
		}

		public boolean put(int key, String value) {
//			System.out.println("Put Key : " + key);
		//	System.out.println("Put Value: " + value);
			int hash = hash(key);
			int i = indexFor(hash, table.length);
			for (Entry e = table[i]; e != null; e = e.next) {
				if (e.hash == hash && e.key == key) {
					e.value = value;
					return false;
				}
			}

			addEntry(hash, key, value, i);
			return true;
		}

		static int hash(int hh) {
			int h = (int) (hh ^ (hh >>> 32));
			h ^= (h >>> 20) ^ (h >>> 12);
			return h ^ (h >>> 7) ^ (h >>> 4);
		}

		static int indexFor(int h, int length) {
			return h & (length - 1);
		}

		void addEntry(int hash, int key, String value, int bucketIndex) {

			Entry old = table[bucketIndex];
			LinkedEntry e = new LinkedEntry(hash, key, value, old);
			table[bucketIndex] = e;
			e.addBefore(header);
			size++;

			if (size++ >= threshold)
				resize(2 * table.length);
		}

		void resize(int newCapacity) {
			Entry[] oldTable = table;
			int oldCapacity = oldTable.length;
			if (oldCapacity == MAXIMUM_CAPACITY) {
				threshold = Integer.MAX_VALUE;
				return;
			}

			Entry[] newTable = new Entry[newCapacity];
			transfer(newTable);
			table = newTable;
			threshold = (int) (newCapacity * loadFactor);
		}

		void transfer(Entry[] newTable) {
			Entry[] src = table;
			int newCapacity = newTable.length;
			for (int j = 0; j < src.length; j++) {
				Entry e = src[j];
				if (e != null) {
					src[j] = null;
					do {
						Entry next = e.next;
						int i = indexFor(e.hash, newCapacity);
						e.next = newTable[i];
						newTable[i] = e;
						e = next;
					} while (e != null);
				}
			}
		}

		final String get(int key) {
			int hash = hash(key);
			
			for (Entry e = table[indexFor(hash, table.length)]; e != null; e = e.next) {
				if (e.hash == hash && e.key == key)
					return e.value;
			}
			return null;

		}
		
		 final Entry getEntry(int key) {
		        int hash = hash(key);
		        for (Entry e = table[indexFor(hash, table.length)];
		             e != null;
		             e = e.next) {
		            if (e.hash == hash && e.key == key )
		                return e;
		        }
		        return null;
		    }

		
		public int size()
		{
			return size;
		}

		private final class EntrySet extends AbstractSet<Entry> {
			public Iterator<Entry> iterator() {
				return newEntryIterator(); // returns a HashIterator...
			}

			// ...

			@Override
			public int size() {
				return size;
			}
		}

		Iterator<Entry> newEntryIterator() {
			return new EntryIterator();
		}

		private class EntryIterator extends LinkedHashIterator<Entry> {
			public Entry next() {
				return nextEntry();
			}
		}

		private abstract class LinkedHashIterator<T> implements Iterator<T> {
			LinkedEntry nextEntry = header.after;
			LinkedEntry lastReturned = null;

			public boolean hasNext() {
				return nextEntry != header;
			}

			public void remove() {
				if (lastReturned == null)
					throw new IllegalStateException();
				/*
				 * PrimitiveIntHashMap.this.remove(lastReturned.key); lastReturned =
				 * null;
				 */
			}

			LinkedEntry nextEntry() {
				if (nextEntry == header)
					throw new NoSuchElementException();

				LinkedEntry e = lastReturned = nextEntry;
				nextEntry = e.after;
				return e;
			}
		}

		static class Entry {
			final int key;
			String value;
			Entry next;
			final int hash;

			Entry(int h, int k, String v, Entry n) {
				next = n;
				key = k;
				value = v;
				hash = h;
			}

			public final int getKey() {
				return key;
			}

			public final String getValue() {
				return value;
			}

			public final String setValue(String newValue) {
				String oldValue = value;
				value = newValue;
				return oldValue;
			}

			public final boolean equals(Object o) {
				if (!(o instanceof Entry))
					return false;
				Entry e = (Entry) o;
				if (this.key == e.key) {
					if (this.value != null && this.value.equals(e.getValue()))
						return true;
				}
				return false;
			}

		}

		static class LinkedEntry extends Entry {
			LinkedEntry before, after;

			LinkedEntry(int hash, int key, String value, Entry next) {
				super(hash, key, value, next);
			}

			private void remove() {
				before.after = after;
				after.before = before;
			}

			/**
			 * Inserts this entry before the specified existing entry in the list.
			 */
			private void addBefore(LinkedEntry existingEntry) {
				after = existingEntry;
				before = existingEntry.before;
				before.after = this;
				after.before = this;
			}

		}

		public EntrySet entrySet() {
			return new EntrySet();
		}

		public boolean containsKey(int key) {
			return getEntry(key) != null;
		}

	}

}
